<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>员工</title>
	<link rel="stylesheet" href="/js/plugin/layui-v2.3.0/layui/css/layui.css">
	<link rel="stylesheet" href="/css/reset.css">
	<link rel="stylesheet" href="/css/index.css">
	<script src="/js/jquery-2.1.1.min.js"></script>
	<script src="/js/plugin/layui-v2.3.0/layui/layui.js"></script>
</head>
<body>
	<div class="kb-out-box">
		<div class="kb-content">	
			<section class="kb-content-container">
				<header class="nav-header">
					<h2 class="nav-section-header-title">
						<span>全公司</span>
						<div class="f-right">
							<button class="layui-btn layui-btn-normal layui-btn-radius" id="add-btn" ><i class="layui-icon"> &#xe654;</i>添加分店</button>	
						</div>
				    </h2>					
				</header>
				<div class="nav-section-content-container">
					<div>
						<div class="city-subbranch clearfix" id="projectLsit">
							
							
						</div>
					</div>
				</div>
			</section>
		</div>
	</div>
</body>
<script>
	$(function(){
		runAsync();
		layui.use(['element',"layer","form"], function(){
			var layer=layui.layer,form = layui.form;
		});
		$("#add-btn").on("click",function(){
			parent.layer.open({
			  type: 2, 
			  title:"添加新分店",
			  area: ['700px','90%'],
		      shade: [0.6, '#010101'],
		      zIndex:800,
			  content:"/app/project/add" , //这里content是一个普通的String
			  end: function () {
				  runAsync();  
		      }
			});		
		})
		$(".city-subbranch").on("click",".subbranch-message",function(){
			parent.location.hash="#projectIndex/"+this.id;
			parent.getHash();
		})
	})
	//封装获取数据
	function runAsync(url){
	　　var def = $.Deferred();
	　	var url=url || "/app/project/listdata";
		jQuery.ajax({
	        type:"post",
	        async:false,
	        url:url,
	        dataType:"json",
	        data:{},
	        success:function(data){
	        	resolve(data.data);
	        }
	    })
	}
	function resolve(data){
		var cont="<header>北京</header>";
		for (var i = 0; i < data.length; i++) {
			cont+='<div class="subbranch-message" id="'+data[i].id+'"><a href="#locations/3"><img src="../../images/jtdoor_pic.jpg" alt="'+data[i].projectName+'">'
			+'<div class="space_location"><p>'+data[i].projectName+'</p><div class="location_info flex"><div class="loc_info_list">'
			+'<P>工位总数</P><P><span>17<span class="small-page">个</span></span></P></div><div class="loc_info_list"><P>工位总数</P>'
			+'<P><span>17<span class="small-page">个</span></span></P></div><div class="loc_info_list"><P>工位总数</P>'
			+'<P><span>17<span class="small-page">个</span></span></P></div></div></div></a></div>';
		}
		
		$("#projectLsit").html(cont)
	}
	
</script>
</html>